import { createApp } from "vue";
import App from "./App.vue";
import "./registerServiceWorker";
import router from "./router";
import store from "./store";
import ElementPlus from "element-plus";
import Particles from "particles.vue3";

import "element-plus/dist/index.css";
import locale from "element-plus/lib/locale/lang/zh-cn";
import * as ElIconModules from "@element-plus/icons-vue";
import api from "@/utils";
import "@/assets/icon/iconfont.css";
import { theme } from "@/components/dialog/theme/theme";
const app = createApp(App);

const { currentTheme } = theme();

// 注册全局变量
app.provide("$api", api);
// app.config.globalProperties.$api = api;

// 注册全局主题
app.provide("currentTheme", currentTheme);

// 统一注册Icon图标
for (const iconName in ElIconModules) {
  if (Reflect.has(ElIconModules, iconName)) {
    const item = ElIconModules[iconName];
    app.component(iconName, item);
  }
}
// 注册组件
app.use(ElementPlus, { locale }).use(Particles).use(store).use(router);

// 挂载
app.mount("#app");
